package soo.view;

import java.io.File;
import java.util.Calendar;
import org.apache.log4j.Logger;
import soo.service.Fubao;
import soo.service.LoginCodeParser;

public class MainView111 {

    static Logger log = Logger.getLogger(MainView111.class.getName());

    /**
     * @param args
     */
    public static void main(String[] args) {
        File f = new File(Fubao.TOP_DIR);
        if (!f.exists()) {
            f.mkdirs();
        }

        String name = "513902198601150022";

        String pwd = "yxy1986115";

        String docUrl = "http://guahao.zjol.com.cn/DoctorInfo.Aspx?DEPART=1183&ID=2930";

        Fubao fubao = new Fubao(docUrl);
        fubao.doGetLoginVerifyCodeImg();
        String verifyCode = LoginCodeParser.getFubaoImgCode(Fubao.LOGIN_CODE_URL);

        System.out.println("your Enter  VerifyCode is " + verifyCode);
        System.out.println("java name:" + name);
        System.out.println("java pwd:" + pwd);
        System.out.println("java url:" + docUrl);
        Calendar startCal = Calendar.getInstance();
        int hour = 13;
        int min = 59;
        startCal.set(Calendar.HOUR_OF_DAY, hour);
        startCal.set(Calendar.MINUTE, min);
        startCal.set(Calendar.MILLISECOND, 0);
        System.out.println("start date:" + startCal.getTime());

        String loginResult = fubao.doLogin(name, pwd, verifyCode);
        if (loginResult.indexOf("OK") < 0) {
            return;
        }
        fubao.doBookTicket(startCal.getTimeInMillis());

    }
}
